/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "aluguer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Aluguer.findAll", query = "SELECT a FROM Aluguer a"),
    @NamedQuery(name = "Aluguer.findByIdAluguer", query = "SELECT a FROM Aluguer a WHERE a.idAluguer = :idAluguer"),
    @NamedQuery(name = "Aluguer.findByDescricaoAluguer", query = "SELECT a FROM Aluguer a WHERE a.descricaoAluguer = :descricaoAluguer"),
    @NamedQuery(name = "Aluguer.findByDataEntrega", query = "SELECT a FROM Aluguer a WHERE a.dataEntrega = :dataEntrega"),
    @NamedQuery(name = "Aluguer.findByDataSaida", query = "SELECT a FROM Aluguer a WHERE a.dataSaida = :dataSaida")})
public class Aluguer implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataEntrega")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataEntrega;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataSaida")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataSaida;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idAluguer")
    private Integer idAluguer;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "descricaoAluguer")
    private String descricaoAluguer;
    @JoinTable(name = "itemAluguer", joinColumns = {
        @JoinColumn(name = "fkidAluguer", referencedColumnName = "idAluguer")}, inverseJoinColumns = {
        @JoinColumn(name = "fkidVeiculo", referencedColumnName = "idVeiculo")})
    @ManyToMany
    private List<Veiculo> veiculoList;
    @JoinColumn(name = "fkCliente", referencedColumnName = "idCliente")
    @ManyToOne(optional = false)
    private Cliente fkCliente;

    public Aluguer() {
    }

    public Aluguer(Integer idAluguer) {
        this.idAluguer = idAluguer;
    }

    public Aluguer(Integer idAluguer, String descricaoAluguer, Date dataEntrega, Date dataSaida) {
        this.idAluguer = idAluguer;
        this.descricaoAluguer = descricaoAluguer;
        this.dataEntrega = dataEntrega;
        this.dataSaida = dataSaida;
    }

    public Integer getIdAluguer() {
        return idAluguer;
    }

    public void setIdAluguer(Integer idAluguer) {
        this.idAluguer = idAluguer;
    }

    public String getDescricaoAluguer() {
        return descricaoAluguer;
    }

    public void setDescricaoAluguer(String descricaoAluguer) {
        this.descricaoAluguer = descricaoAluguer;
    }

    @XmlTransient
    public List<Veiculo> getVeiculoList() {
        return veiculoList;
    }

    public void setVeiculoList(List<Veiculo> veiculoList) {
        this.veiculoList = veiculoList;
    }

    public Cliente getFkCliente() {
        return fkCliente;
    }

    public void setFkCliente(Cliente fkCliente) {
        this.fkCliente = fkCliente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAluguer != null ? idAluguer.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Aluguer)) {
            return false;
        }
        Aluguer other = (Aluguer) object;
        if ((this.idAluguer == null && other.idAluguer != null) || (this.idAluguer != null && !this.idAluguer.equals(other.idAluguer))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Aluguer[ idAluguer=" + idAluguer + " ]";
    }

    public Date getDataEntrega() {
        return dataEntrega;
    }

    public void setDataEntrega(Date dataEntrega) {
        this.dataEntrega = dataEntrega;
    }

    public Date getDataSaida() {
        return dataSaida;
    }

    public void setDataSaida(Date dataSaida) {
        this.dataSaida = dataSaida;
    }
    
}
